import React, { Component } from 'react';
import _ from 'lodash';


export default class State3 extends Component {
  //声明状态
  state = {
    bg: 'rgb(0,0,0)'
  }
  
  // 声明事件回调  handle 处理 click 点击
  handleClick = () => {
    this.setState({
      bg: `rgb(${_.random(100,200)},${_.random(100, 200)},${_.random(100, 200)})`
    })
  }

  render() {
    return (
      <div 
        onClick={this.handleClick}
        style={{background: this.state.bg, width: '400px', height: '300px'}}></div>
    )
  }
}
